package com.example.sigthp_p_department.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        int s = TestClass.Iverson.i.WriteSomething(520);
        String s2 = TestClass.TestClass2.s.MyTest("^_^  ");
        TextView tv = (TextView) findViewById(R.id.tv);
        TextView tv_2 = (TextView) findViewById(R.id.tv_2);
        TextView tv_3 = (TextView) findViewById(R.id.tv_3);
        tv.setText(String.valueOf(s2));
        String s1 = "新世界";

        //软引用
        SoftReference<String> sr = new SoftReference<>(s1);
        System.gc();
        tv_2.setText(sr.get());

        //弱引用
        String s3 = new String("我很好");
        WeakReference<String> wr = new WeakReference<>(s3);
        System.gc();
        tv_3.setText(wr.get());
    }
}
